package com.sskj.pay.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.bean.UploadBean;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.pay.http.HttpConfig;
import com.sskj.pay.ui.activity.AddPayTypeActivity;


public class AddPayTypeActivityPresenter extends BasePresenter<AddPayTypeActivity> {

    public void upload(String filePath) {
        httpService.upload(filePath)
                .execute(new JsonCallBack<HttpData<UploadBean>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<UploadBean>> response) {
                        mView.uploadSuccess(response.body().getData());
                    }
                });
    }

    public void addOrEditPayType(boolean isAdd, String type, String account, String img, String bank, String branch, String pwd) {
        httpService.addOrEditPayType(isAdd, type, account, img, bank, branch, pwd)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        ToastUtil.showShort(httpData.getMsg());
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.addOrEditSuccess();
                        }
                    }
                });
    }

}
